// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/efficiency/api/EnergySupplyApi'

import ComClass from '@api/ComQuery'
import ListClass from '@api/efficiency/model/EnergySupplyElectricQueryReq'

const DownloadClass = ListClass

const CLIENT = CORE.grpcCLIENT(Client)
const COM = [ComClass, 'comQuery']

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 列表 —————————————————————————————— //

  async getList(param, TIP = '查询监测点记录') {
    const DTO = CORE.grpcDTO(ListClass, param, COM)
    const resp = await CORE.grpc(TIP, CLIENT, 'energySupplyElectricQuery', DTO)
    return [resp.comQuery.totalCount, resp.content || []]
  },

  // —————————————————————————————— 下载 —————————————————————————————— //

  async downloadWave(downParam, TIP = '导出谐波分析') {
    const DTO = CORE.grpcDTO(DownloadClass, downParam)
    await CORE.grpcDownload(TIP, CLIENT, 'harmonicExport', DTO)
    return CORE.grpcOK(TIP)
  },

  // —————————————————————————————— 下载 —————————————————————————————— //

  async downloadUnbalance(downParam, TIP = '导出不平衡分析') {
    const DTO = CORE.grpcDTO(DownloadClass, downParam)
    await CORE.grpcDownload(TIP, CLIENT, 'outOfBalanceExport', DTO)
    return CORE.grpcOK(TIP)
  },
}
